#include "s5pv210.h"


void mem_ctrl_init(void)
{
	unsigned int i = 0x10000;

	/* DMC0 initialization at single Type*/
	PHYCONTROL00_REG = 0x00101000;
	PHYCONTROL01_REG = 0x00000086;
	PHYCONTROL00_REG = 0x00101002;
	PHYCONTROL00_REG = 0x00101003;
	
	for(i = 0x10000;i>1;i--);
	PHYCONTROL00_REG = ((PHYSTATUS0_REG&0x3fc0)<<18)|0x100000|0x1000|0x03;

	/* setting DDR2 */
	DMC0_CONCONTROL = 0x0FFF2010;		
	DMC0_MEMCONTROL = 0x00212400;		
	DMC0_MEMCONFIG0 = 0x30F01313;		
	DMC0_MEMCONFIG1 = 0x40F01313;		
	DMC0_PRECHCONFIG = 0xFF000000;		
	DMC0_TIMINGAREF = 0x00000618;
	DMC0_TIMINGROW = 0x28233287;
	DMC0_TIMINGDATA = 0x23240304;
	DMC0_TIMINGPOWER = 0x09C80232;
	
	DMC0_DIRECTCMD = 0x07000000;
	DMC0_DIRECTCMD = 0x01000000;
	DMC0_DIRECTCMD = 0x00020000;
	DMC0_DIRECTCMD = 0x00030000;
	DMC0_DIRECTCMD = 0x00010400;
	DMC0_DIRECTCMD = 0x00000542;
	DMC0_DIRECTCMD = 0x01000000;
	DMC0_DIRECTCMD = 0x05000000;
	DMC0_DIRECTCMD = 0x05000000;
	DMC0_DIRECTCMD = 0x00000442;
	DMC0_DIRECTCMD = 0x00010780;
	DMC0_DIRECTCMD = 0x00010400;
	DMC0_DIRECTCMD = 0x07100000;
	DMC0_DIRECTCMD = 0x01100000;
	DMC0_DIRECTCMD = 0x00120000;
	DMC0_DIRECTCMD = 0x00130000;
	DMC0_DIRECTCMD = 0x00110400;
	DMC0_DIRECTCMD = 0x00100542;
	DMC0_DIRECTCMD = 0x01100000;
	DMC0_DIRECTCMD = 0x05100000;
	DMC0_DIRECTCMD = 0x05100000;
	DMC0_DIRECTCMD = 0x00100442;
	DMC0_DIRECTCMD = 0x00110780;
	DMC0_DIRECTCMD = 0x00110400;
	DMC0_CONCONTROL = 0x0FF02030;
	DMC0_PWRDNCONFIG = 0xFFFF00FF;
	DMC0_MEMCONTROL = 0x00202400;

	/* DMC1 initialization */
	PHYCONTROL10_REG = 0x00101000;
	PHYCONTROL11_REG = 0x00000086;
	PHYCONTROL10_REG = 0x00101002;
	PHYCONTROL10_REG = 0x00101003;

	for(i = 0x10000;i>1;i--);
	PHYCONTROL10_REG = ((PHYSTATUS1_REG&0x3fc0)<<18)|0x100000|0x1000|0x03;

	/* settinf fot DDR2 */
	DMC1_CONCONTROL = 0x0FFF2010;		
	DMC1_MEMCONTROL = 0x00202400;		
	DMC1_MEMCONFIG0 = 0x40F01313;		
	DMC1_MEMCONFIG1 = 0x50F01313;		
	DMC1_PRECHCONFIG = 0xFF000000;		
	DMC1_TIMINGAREF = 0x00000618;
	DMC1_TIMINGROW = 0x28233287;
	DMC1_TIMINGDATA = 0x23240304;
	DMC1_TIMINGPOWER = 0x09C80232;

	DMC1_DIRECTCMD = 0x07000000;
	DMC1_DIRECTCMD = 0x01000000;
	DMC1_DIRECTCMD = 0x00020000;
	DMC1_DIRECTCMD = 0x00030000;
	DMC1_DIRECTCMD = 0x00010400;
	DMC1_DIRECTCMD = 0x00000542;
	DMC1_DIRECTCMD = 0x01000000;
	DMC1_DIRECTCMD = 0x05000000;
	DMC1_DIRECTCMD = 0x05000000;
	DMC1_DIRECTCMD = 0x00000442;
	DMC1_DIRECTCMD = 0x00010780;
	DMC1_DIRECTCMD = 0x00010400;
	DMC1_DIRECTCMD = 0x07100000;
	DMC1_DIRECTCMD = 0x01100000;
	DMC1_DIRECTCMD = 0x00120000;
	DMC1_DIRECTCMD = 0x00130000;
	DMC1_DIRECTCMD = 0x00110400;
	DMC1_DIRECTCMD = 0x00100542;
	DMC1_DIRECTCMD = 0x01100000;
	DMC1_DIRECTCMD = 0x05100000;
	DMC1_DIRECTCMD = 0x05100000;
	DMC1_DIRECTCMD = 0x00100442;
	DMC1_DIRECTCMD = 0x00110780;
	DMC1_DIRECTCMD = 0x00110400;
	DMC1_CONCONTROL = 0x0FF02030;
	DMC1_PWRDNCONFIG = 0xFFFF00FF;
	DMC1_MEMCONTROL = 0x00202400;
}

void uart_init(void)
{
	S5PV210_UART *uart = (S5PV210_UART *)(0xE2900000);//uart0

	__REG(0xE0200000) = 0x2222;//config GPA0_0/1/2/3 as uart mode

	uart->UFCON = 0x0;
	uart->UMCON = 0x0;
	uart->ULCON = 0x3;		//data=8bit
	uart->UCON = 0x3c5;		//polling
	uart->UBRDIV = 34;
	uart->UDIVSLOT = 0xdddd;
	uart->UTXH= 'A';
}


